// pages/addinfo/addinfo.js
const request=require('../../util/request.js')
const instruct = require('../../util/tspl')
import bleDisNetwork from '../../util/bleDisNetwork'
Page({

  /**
   * 页面的初始数据
   */
  data: {
    code:'',//使用的code
    barcode: "F251110010001-01",
    box_no: "001",
    item_name: "45-54",
    oper_name: "开果",
    inv_name: "AAA",
    cust_code: "00001",
    order_no: "F25111001",
    batch_no: "111",
    note: "111",
    fid: "167495",
    f_entry_id: "18",
    f_order_id: "1177",
    showstring:200,
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    console.log(options,"options")
    this.setData({
      code:options.id
    })
    this.getList()

  },
  
  getList(search="",date="") {
    var that = this;
      let tmp = {
        code:that.data.code
      }
    request.requestGet('fruit/get_barcode_info', tmp, "加载中",function (res) {
        console.log(res,"=====res")
      if(res.status === 200){
        that.setData({
          barcode: res.data.barcode,
          box_no: res.data.box_no,
          item_name:res.data.item_name,
          oper_name:res.data.oper_name,
          inv_name: res.data.inv_name,
          cust_code: res.data.cust_code,
          order_no: res.data.order_no,
          batch_no:res.data.batch_no,
          note:res.data.note,
          fid:res.data.fid,
          f_entry_id: res.data.f_entry_id,
          f_order_id: res.data.f_order_id,
          showstring:res.msg
        })
      }else if(res.status === 400){
        that.setData({showstring:res.msg})
      }
      }, function (res) {
        console.log(res,"请求失败")
      },
    )

  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {
    // console.log('走到onshow')
    // this.getList()
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {

  },
  submit(event){
  },
  bindKeyInputVant(event){
    let valueName = event.target.dataset.variable;
    let name = `formData.${valueName}`;
    this.setData({
      [valueName]:event.detail
    });
  },
  onReachBottom() {
    if(this.data.flag){
      this.setData({
        flag:false
      })
      this.getList(); // 疯狂的请求的方法
    }
  },
})